// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0

component Foo {
    popup := PopupWindow {
        Rectangle { @children }
    }
}

component Issue5852 {
    p := PopupWindow {
//       ^error{Cannot access the inside of a PopupWindow from enclosing component}
        input := TextInput {}
    }
    TouchArea {
        clicked => {
            p.show();
            input.focus();
        }
    }
}


export X := PopupWindow {
//       ^warning{':=' to declare a component is deprecated. The new syntax declare components with 'component MyComponent {'. Read the documentation for more info}
//          ^^error{PopupWindow cannot be the top level}

    Rectangle { // FIXME, the error should be located on property access (#4438)
//  ^error{Access to property 'inner.opacity' which is inlined into a PopupWindow via @children is forbidden}

        popup := PopupWindow {  // FIXME, the error should be located on property access (#4438)
//               ^error{Cannot access the inside of a PopupWindow from enclosing component}

            r := Rectangle {
            }
        }

        background: r.background;

        Foo {
            inner := Rectangle { opacity: 0.5; }
        }
        opacity: inner.opacity;
    }


    if true : PopupWindow {}
//            ^error{PopupWindow cannot be directly repeated or conditional}
    for abc in [1] : PopupWindow {}
//                   ^error{PopupWindow cannot be directly repeated or conditional}

    Issue5852 {}
}
